<template>
	<view class="tab_container">
		<view v-if="tabtarIndex==0">
			<Home ref="achievement" :opacityVal="opacityVal" :offsetTop="offsetTop">
			</Home>
		</view>
		<view v-if="tabtarIndex==1">
			<Good ref="good"></Good>
		</view>
		<view v-if="tabtarIndex==2">
			<Order :cureet="cureet" ref="order"></Order>
		</view>
		<view v-if="tabtarIndex==3">
			<User @goOrder="goOrder" ref="order"></User>
		</view>
		<tui-tabbar :current="tabtarIndex" @click="tabbarSwitch" backdropFilter backgroundColor="#fff" :tabBar="tabBar"
			color="#666" selectedColor="#2FCC71"></tui-tabbar>
	</view>
</template>

<script>
	import Home from "@/procurement/home/home.vue";
	import Good from "@/procurement/good/good.vue";
	import Order from "@/procurement/order/order.vue";
	import User from "@/procurement/user/user.vue";
	export default {
		data() {
			return {
				cureet: 0,
				opacityVal: 0,
				tabtarIndex: 0,
				tabBar: [{
						// pagePath: '/pages/business/businessMy/index',
						text: '首页',
						iconPath: '/static/procure/tab_home@3x.png',
						selectedIconPath: '/static/procure/tab_home_selected@3x.png',
						// num: 1,
						// isDot: false
					},
					{
						// pagePath: '/pages/business/businessMy/index',
						text: '商品',
						iconPath: '/static/procure/tab_goods@3x.png',
						selectedIconPath: '/static/procure/tab_goods_selected@3x.png',
						// num: 1,
						// isDot: false
					},
					{
						// pagePath: '/pages/business/businessMy/index',
						text: '订单',
						iconPath: '/static/procure/tab_order@3x.png',
						selectedIconPath: '/static/procure/tab_order_selected@3x.png',
						// num: 1,
						// isDot: false
					},
					{
						// pagePath: '/pages/business/businessMy/index',
						text: '我的',
						iconPath: '/static/procure/tab_mine@3x.png',
						selectedIconPath: '/static/procure/tab_mine_selected@3x.png',
						// num: 2,
						// isDot: true
					}
				],

			}
		},
		computed: {
			offsetTop() {
				console.log(uni.getSystemInfoSync().statusBarHeight);
				return Number(uni.getSystemInfoSync().statusBarHeight + 44)
			}
		},
		components: {
			Home,
			Good,
			Order,
			User
		},
		onShow() {
			if (this.tabtarIndex === 1) {
				console.log(9999);
				this.$refs.good.reshf()
			}
		},
		onPageScroll(e) {
			if (this.tabtarIndex === 0) {
				// console.log("滚动距离为：" + e.scrollTop);
				let top = e.scrollTop;
				this.opacityVal = top > 200 ? 1 : top * 0.005;
				// console.log(this.opacityVal);
			}

		},
		onReachBottom() {
			if (this.tabtarIndex === 1) {
				console.log(9999);
				this.$refs.good.botom()
			}
		},
		methods: {
			goOrder(index) {
				this.tabtarIndex = 2
				this.cureet = index
			},
			tabbarSwitch(e) {
				// console.log(e)
				this.tabtarIndex = e.index;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab_container {
		padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
	}
</style>